<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDevicesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('devices', function (Blueprint $table) {
            $table->increments('id');
            $table->string("device_num")->nullable()->comment("设备号");
            $table->string("device_name")->nullable()->comment("设备名称");
            $table->string("device_type")->nullable()->comment("设备类型");
            $table->integer("device_img_id")->default(0)->comment("设备图");
            $table->string("device_img_url")->nullable()->comment("设备图链接");
            $table->integer("status")->default(0)->comment("设备状态，0未启用，1已启用，2已绑定商家");
            $table->softDeletes();
            $table->timestamps();
        });
        Schema::create('user_devices', function (Blueprint $table) {
            $table->increments('id');
            $table->integer("user_id")->default(0)->comment("用户id");
            $table->string("device_num")->nullable()->comment("设备号");
            $table->string("device_name")->nullable()->comment("设备名称");
            $table->string("device_type")->nullable()->comment("设备类型");
            $table->integer("is_online")->default(0)->comment("设备在线状态，0不在线，1在线");
            $table->decimal("peel")->default(0)->comment("去皮重量，克");
            $table->decimal("max_num")->default(0)->comment("满水重量，克");
            $table->decimal("last_num")->default(0)->comment("最后重量，克");
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('devices');
    }
}
